package com.networks;

import java.net.InetSocketAddress;

// 端口类 基本使用InetSocketAddress
public class Ports {
    public static void main(String[] args) {
        // 端口类
        InetSocketAddress isa = new InetSocketAddress("127.0.0.1", 8080);
        System.out.println(isa.getAddress());   // 获取地址 /127.0.0.1
        System.out.println(isa.getHostName());  // 获取地址 tiku.com hosts文件
        System.out.println(isa.getPort());      // 获取端口 8080

        InetSocketAddress isaLocal = new InetSocketAddress("localhost", 8080);
        System.out.println(isaLocal.getAddress());   // 获取地址 localhost/127.0.0.1
    }
}
